#ifndef _PLANE_H
#define _PLANE_H

#include "Common.h"
#include "Primitive.h"

namespace Pandora
{
	class CPlane : public CPrimitive
	{
		CVector3 normal;
		float d;
	public:
		CPlane(CVector3& n, float _d) : normal(n), d(_d) {}
		CPlane(CVector3* n, float _d) : normal(*n), d(_d) {}
		CPlane(float x, float y, float z, float _d) : normal(CVector3(x, y, z)), d(_d) {}
		CPlane(CVector3& n, CVector3& point) : normal(n), d(-point.Dot(normal)) {}
		CPlane(CVector3* n, CVector3& point) : normal(*n), d(-point.Dot(normal)) {}
		CPlane(CVector3& n, CVector3* point) : normal(n), d(-point->Dot(normal)) {}
		CPlane(CVector3* n, CVector3* point) : normal(*n), d(-point->Dot(normal)) {}
		CPlane(float x, float y, float z, CVector3& point) : normal(CVector3(x, y, z)), d(-point.Dot(normal)) {}
		CPlane(float x, float y, float z, CVector3* point) : normal(CVector3(x, y, z)), d(-point->Dot(normal)) {}
		CPlane(CVector3& n, float x, float y, float z) : normal(n), d(-CVector3(x, y, z).Dot(normal)) {}
		CPlane(CVector3* n, float x, float y, float z) : normal(*n), d(-CVector3(x, y, z).Dot(normal)) {}
		CPlane(float x, float y, float z, float px, float py, float pz) : normal(CVector3(x, y, z)), d(-CVector3(px, py, pz).Dot(normal)) {}

		CVector3& GetPosition() { return normal*d; }
		CVector3 GetNormal(CVector3& pos) { return normal; }
		CVector3 GetNormal(CVector3* pos) { return normal; }
		PRIMITIVES GetType() { return PLANE; }

		int Intersect(CRay& ray, float &t);
		int Intersect(CRay* ray, float &t);

		void SetNormal(CVector3& n) { normal = n; }
		void SetNormal(CVector3* n) { normal = *n; }
		void SetNormal(float x, float y, float z) { normal = CVector3(x, y, z); }
		void SetOffset(float p) { d = p; }
	};

}; //namespace Pandora

#endif /* _PLANE_H */